#ifndef __TOKEN_H__
#define __TOKEN_H__

#include "common.h"

#include <fstream>
#include <functional>

using std::ifstream;
using std::function;

class Token;

typedef function<bool(char)> RecognizerFunction;
typedef function<Token*(char,ifstream&)> ExtractorFunction;

class TokenExtractor
{
private:
	RecognizerFunction recognizer;
	ExtractorFunction extractor;

public:
	TokenExtractor(RecognizerFunction recognizer, ExtractorFunction extractor)
	{
		this->recognizer = recognizer;
		this->extractor = extractor;
	}

	RecognizerFunction getRecognizer() const
	{
		return recognizer;
	}

	ExtractorFunction getExtractor() const
	{
		return extractor;
	}
};

class Token
{
private:
	string token_string;

public:
	Token()
	{
	}

	Token(string& str)
	{
		token_string = str;
	}

	string getTokenString() const
	{
		return token_string;
	}

	virtual string print() const = 0;
	virtual string printType() const = 0;
};

#endif
